package withdi;

public class UserService {

    public UserService(){
        System.out.println("实例化service");
    }

    //不需要自己实例化依赖对象，那么谁去做这件事呢？
    private UserDao userDao;

    //需要提供setter方法
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public boolean isExists(int userId){
        boolean flag=false;
        String userName=userDao.selectUsername(userId);
        if(userName!=null&&!"".equals(userName)){
            flag=true;
        }
        return flag;
    }
}
